<?php

namespace app\api\controller\ykjp\product;

use app\common\controller\Api;

/**
 * 单位接口
 */
class Unit extends Api
{

    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = '*';
   

    public function getUnitList()
    {
        $row = \app\admin\model\ykjp\product\Unit::where('deletetime',null)->select();
        $this->success('返回成功', ['data' => $row]);
    }

    public function deleteUnit()
    {
        $id = input('post.id');
        $row = \app\admin\model\ykjp\product\Unit::where("id", $id)->delete();
        $this->success('返回成功', ['data' =>'删除成功！']);
    }

    public function addUnit()
    {

        $name = input('post.name');
        $model = new \app\admin\model\ykjp\product\Unit;
        $time = time();


        $model->insert([
            'firmid' => null,
            'createtime' => $time,
            'name' => $name,
            'updatetime' => $time,
        ]);

        $this->success('返回成功', ['data' =>'添加成功！']);
    }

}
